package com.kancy.stream.rabbit.properties;

import java.util.HashMap;
import java.util.Map;

/**
 * ChannelProperties
 *
 * @author kancy
 * @date 2020/3/8 15:00
 */
public class ChannelProperties {
    private static final String DEFAULT_MESSAGE_CONVERTER_BEAN_NAME = "messageConverter";
    /**
     * 绑定key
     */
    private String bindingKey;

    /**
     * 消息消费者 key -> message-type
     */
    private Map<String, ConsumerProperties> consumer = new HashMap<>();


    /**
     * 消息生产者 key -> message-type
     */
    private Map<String, ProducerProperties> producer = new HashMap<>();

    /**
     * 消息转换器
     */
    private String messageConverter = DEFAULT_MESSAGE_CONVERTER_BEAN_NAME;

    /**
     * 并发数
     */
    private int concurrency = 1;

    /**
     * 优先级
     * Larger numbers indicate higher priority, and both positive and negative numbers can be used.
     */
    private Integer priority;

    /**
     * 组
     */
    private String group;

    /**
     * 自动启动
     */
    private boolean autoStartup = true;

    /**
     * When true, a single consumer in the container will have exclusive use of the queue,
     * preventing other consumers from receiving messages from the
     * queues. When true, requires a concurrency of 1. Default false.
     */
    private boolean exclusive = false;

    public String getMessageConverter() {
        return messageConverter;
    }

    public void setMessageConverter(String messageConverter) {
        this.messageConverter = messageConverter;
    }

    public int getConcurrency() {
        return concurrency;
    }

    public void setConcurrency(int concurrency) {
        this.concurrency = concurrency;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public boolean isAutoStartup() {
        return autoStartup;
    }

    public void setAutoStartup(boolean autoStartup) {
        this.autoStartup = autoStartup;
    }

    public boolean isExclusive() {
        return exclusive;
    }

    public void setExclusive(boolean exclusive) {
        this.exclusive = exclusive;
    }

    public Map<String, ConsumerProperties> getConsumer() {
        return consumer;
    }

    public void setConsumer(Map<String, ConsumerProperties> consumer) {
        this.consumer = consumer;
    }

    public String getBindingKey() {
        return bindingKey;
    }

    public void setBindingKey(String bindingKey) {
        this.bindingKey = bindingKey;
    }

    public Map<String, ProducerProperties> getProducer() {
        return producer;
    }

    public void setProducer(Map<String, ProducerProperties> producer) {
        this.producer = producer;
    }



    /**
     * ConsumerProperties
     *
     * @author kancy
     * @date 2020/3/8 15:06
     */
    public static class ConsumerProperties {

        /**
         * MessageHandler bean名称
         */
        private String messageHandler = "logMessageHandler";

        /**
         * 异常处理器
         */
        private String exceptionHandler = "logExceptionHandler";

        /**
         * 消息转换器
         */
        private String messageConverter = DEFAULT_MESSAGE_CONVERTER_BEAN_NAME;

        public String getMessageHandler() {
            return messageHandler;
        }

        public void setMessageHandler(String messageHandler) {
            this.messageHandler = messageHandler;
        }

        public String getMessageConverter() {
            return messageConverter;
        }

        public void setMessageConverter(String messageConverter) {
            this.messageConverter = messageConverter;
        }

        public String getExceptionHandler() {
            return exceptionHandler;
        }

        public void setExceptionHandler(String exceptionHandler) {
            this.exceptionHandler = exceptionHandler;
        }
    }

    /**
     * ProducerProperties
     *
     * @author kancy
     * @date 2020/3/8 16:09
     */
    public static class ProducerProperties {
        /**
         * 消息转换器
         */
        private String messageConverter = DEFAULT_MESSAGE_CONVERTER_BEAN_NAME;

        public String getMessageConverter() {
            return messageConverter;
        }

        public void setMessageConverter(String messageConverter) {
            this.messageConverter = messageConverter;
        }
    }


}
